<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <title>docker系列二之制作镜像 | Hexo</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="简介　　docker提供了两种方式创建新的镜像：1. 从已经创建的容器中更新镜像，并且提交这个镜像；2. 使用Dockerfile指令来创建一个镜像。下面我们先讲述如何更新一个镜像，再讲解如何使用Dockerfile文件创建镜像，包括离线和在线两种模式。
更新镜像123456789101112131415161718192021222324#创建容器$ docker run -i -t ubunt">
<meta property="og:type" content="article">
<meta property="og:title" content="docker系列二之制作镜像">
<meta property="og:url" content="http://yoursite.com/2016/01/10/docker/2.docker系列之制作镜像/index.html">
<meta property="og:site_name" content="Hexo">
<meta property="og:description" content="简介　　docker提供了两种方式创建新的镜像：1. 从已经创建的容器中更新镜像，并且提交这个镜像；2. 使用Dockerfile指令来创建一个镜像。下面我们先讲述如何更新一个镜像，再讲解如何使用Dockerfile文件创建镜像，包括离线和在线两种模式。
更新镜像123456789101112131415161718192021222324#创建容器$ docker run -i -t ubunt">
<meta property="og:image" content="http://yoursite.com/images/56A1E033419C483A96D662F5B6F64E97.jpg">
<meta property="og:image" content="http://yoursite.com/images/CA58F7917B31493CA7AD75D773E58ED3.jpg">
<meta property="og:updated_time" content="2016-01-29T17:47:36.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="docker系列二之制作镜像">
<meta name="twitter:description" content="简介　　docker提供了两种方式创建新的镜像：1. 从已经创建的容器中更新镜像，并且提交这个镜像；2. 使用Dockerfile指令来创建一个镜像。下面我们先讲述如何更新一个镜像，再讲解如何使用Dockerfile文件创建镜像，包括离线和在线两种模式。
更新镜像123456789101112131415161718192021222324#创建容器$ docker run -i -t ubunt">
  
    <link rel="alternative" href="/atom.xml" title="Hexo" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  <link rel="stylesheet" href="/css/style.css" type="text/css">
  

</head>
<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">Hexo</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" results="0" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://yoursite.com"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main"><article id="post-docker/2.docker系列之制作镜像" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2016/01/10/docker/2.docker系列之制作镜像/" class="article-date">
  <time datetime="2016-01-09T18:00:00.000Z" itemprop="datePublished">2016-01-10</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/docker/">docker</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      docker系列二之制作镜像
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h2 id="u7B80_u4ECB"><a href="#u7B80_u4ECB" class="headerlink" title="简介"></a>简介</h2><p>　　docker提供了两种方式创建新的镜像：1. 从已经创建的容器中更新镜像，并且提交这个镜像；2. 使用Dockerfile指令来创建一个镜像。下面我们先讲述如何更新一个镜像，再讲解如何使用Dockerfile文件创建镜像，包括离线和在线两种模式。</p>
<h2 id="u66F4_u65B0_u955C_u50CF"><a href="#u66F4_u65B0_u955C_u50CF" class="headerlink" title="更新镜像"></a>更新镜像</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#创建容器</span></span><br><span class="line">$ docker run -i -t ubuntu:<span class="number">14.04</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#修改容器</span></span><br><span class="line">root@d49418a895f8:/<span class="comment"># apt-get install mysql-server</span></span><br><span class="line">root@d49418a895f8:/<span class="comment"># apt-get install mysql-client</span></span><br><span class="line">root@d49418a895f8:/<span class="comment"># apt-get install libmysqlclient-dev</span></span><br><span class="line">root@d49418a895f8:/<span class="comment"># exit</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#提交容器</span></span><br><span class="line">$ docker commit -m=<span class="string">"add mysql"</span> <span class="operator">-a</span>=<span class="string">"shihuacai"</span> d49418a895f8 shihuacai/mysql:v1</span><br><span class="line"><span class="number">4</span>f177bd27a9ff0f6dc2a830403925b5360bfe0b93d476f7<span class="built_in">fc</span>3231110e7f71b1c</span><br><span class="line"><span class="comment">#-m标示是允许我们指定提交的信息，-a标示更新作者</span></span><br><span class="line"><span class="comment">#新镜像来自ID为d49418a895f8的容器</span></span><br><span class="line"><span class="comment">#新镜像的用户名：shihuacai、镜像名：mysql、标签：v1</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#查看新镜像</span></span><br><span class="line">$ docker images</span><br><span class="line">    REPOSITORY      TAG      IMAGE ID           CREATED          VIRTUAL    SIZE </span><br><span class="line">shihuacai/mysql      v1     f15c8436a2fa   <span class="number">58</span> seconds ago       <span class="number">322.5</span>       MB </span><br><span class="line">...</span><br><span class="line"></span><br><span class="line"><span class="comment"># 推送镜像</span></span><br><span class="line">$ docker push shihuacai/mysql  <span class="comment">#需要先创建仓库shihuacai</span></span><br></pre></td></tr></table></figure>
<h2 id="Dockerfile_u79BB_u7EBF_u5236_u4F5Cjdk_u955C_u50CF"><a href="#Dockerfile_u79BB_u7EBF_u5236_u4F5Cjdk_u955C_u50CF" class="headerlink" title="Dockerfile离线制作jdk镜像"></a>Dockerfile离线制作jdk镜像</h2><p>　　1. 进入centos3目录：/usr/local/java，可以看到有如下文件：<img src="/images/56A1E033419C483A96D662F5B6F64E97.jpg" alt="56A1E033419C483A96D662F5B6F64E97.jpg"><br>　　2. 编写Dockerfile文件<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#Build java jdk container image</span></span><br><span class="line">FROM docker.io/centos:latest</span><br><span class="line">MAINTAINER shihuacai&lt;shihuacai1989@<span class="number">126</span>.com&gt;</span><br><span class="line"></span><br><span class="line"><span class="comment">#set java environment</span></span><br><span class="line">ENV JAVA_HOME /usr/<span class="built_in">local</span>/java/jdk1.<span class="number">7</span></span><br><span class="line">ENV CLASSPATH .:<span class="variable">$JAVA_HOME</span>/lib</span><br><span class="line">ENV PATH <span class="variable">$PATH</span>:<span class="variable">$JAVA_HOME</span>/bin</span><br><span class="line"></span><br><span class="line">RUN mkdir /usr/<span class="built_in">local</span>/java</span><br><span class="line"></span><br><span class="line"><span class="comment">#Copy jdk into image</span></span><br><span class="line">ADD jdk1.<span class="number">7.0</span>_60 /usr/<span class="built_in">local</span>/java/jdk1.<span class="number">7</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#VOLUME 创建一个挂载点用于共享目录</span></span><br><span class="line"><span class="comment">#VOLUME ["&lt;mountpoint&gt;"]</span></span><br><span class="line"><span class="comment">#VOLUME ["/data"]</span></span><br></pre></td></tr></table></figure></p>
<p>　　3. 构建镜像<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#下载centos镜像</span></span><br><span class="line">$ docker pull centos:latest</span><br><span class="line"><span class="comment">#构建镜像</span></span><br><span class="line">$ docker build -t shihuacai/centos-jdk7 .</span><br><span class="line"><span class="comment">#Dockerfile在当前目录下，使用.来指定Dockerfile</span></span><br><span class="line"><span class="comment">#启动镜像</span></span><br><span class="line">$ docker run -i -t --name jdk7 shihuacai/centos-jdk7</span><br></pre></td></tr></table></figure></p>
<h2 id="Dockerfile_u79BB_u7EBF_u5236_u4F5Ctomcat_u955C_u50CF"><a href="#Dockerfile_u79BB_u7EBF_u5236_u4F5Ctomcat_u955C_u50CF" class="headerlink" title="Dockerfile离线制作tomcat镜像"></a>Dockerfile离线制作tomcat镜像</h2><p>　　1. 进入centos3目录：/usr/local/java，可以看到有如下文件：<img src="/images/CA58F7917B31493CA7AD75D773E58ED3.jpg" alt="CA58F7917B31493CA7AD75D773E58ED3.jpg"><br>　　2. 编写Dockerfile文件<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#Build java jdk container image</span></span><br><span class="line">FROM docker.io/centos:latest</span><br><span class="line">MAINTAINER shihuacai&lt;shihuacai1989@<span class="number">126</span>.com&gt;</span><br><span class="line"></span><br><span class="line"><span class="comment">#set java environment</span></span><br><span class="line">ENV JAVA_HOME /usr/<span class="built_in">local</span>/java/jdk1.<span class="number">7</span></span><br><span class="line">ENV CLASSPATH .:<span class="variable">$JAVA_HOME</span>/lib</span><br><span class="line">ENV PATH <span class="variable">$PATH</span>:<span class="variable">$JAVA_HOME</span>/bin</span><br><span class="line"></span><br><span class="line">RUN mkdir /usr/<span class="built_in">local</span>/java</span><br><span class="line"></span><br><span class="line">ADD jdk1.<span class="number">7.0</span>_60 /usr/<span class="built_in">local</span>/java/jdk1.<span class="number">7</span></span><br><span class="line"></span><br><span class="line">RUN mkdir /usr/<span class="built_in">local</span>/tomcat</span><br><span class="line">ADD apache-tomcat-<span class="number">7.0</span>.<span class="number">47</span> /usr/<span class="built_in">local</span>/tomcat</span><br><span class="line">RUN chmod +x /usr/<span class="built_in">local</span>/tomcat/bin/catalina.sh</span><br><span class="line">EXPOSE <span class="number">8080</span></span><br><span class="line">CMD /usr/<span class="built_in">local</span>/tomcat/bin/catalina.sh run</span><br></pre></td></tr></table></figure></p>
<p>　　3. 构建镜像<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#构建镜像</span></span><br><span class="line">$ docker build -t shihuacai/tomcat7 .</span><br><span class="line"><span class="comment">#启动镜像</span></span><br><span class="line">$ docker run -i -t <span class="operator">-d</span> -p <span class="number">8080</span>:<span class="number">8080</span> --name tomcat7 shihuacai/tomcat7</span><br><span class="line"><span class="comment">#访问tomcat: http://192.168.241.131:8080/</span></span><br></pre></td></tr></table></figure></p>
<p>　　4. 推送到仓库<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#登录docker hub</span></span><br><span class="line">$ docker login</span><br><span class="line">Username: shihuacai</span><br><span class="line">Password: </span><br><span class="line">Email: shihuacai1989@<span class="number">126</span>.com</span><br><span class="line"></span><br><span class="line"><span class="comment">#推送到docker hub</span></span><br><span class="line">docker push 镜像</span><br></pre></td></tr></table></figure></p>
<h2 id="Dockerfile_u5728_u7EBF_u5236_u4F5Cjdk_u955C_u50CF"><a href="#Dockerfile_u5728_u7EBF_u5236_u4F5Cjdk_u955C_u50CF" class="headerlink" title="Dockerfile在线制作jdk镜像"></a>Dockerfile在线制作jdk镜像</h2><p>　　下面我们看看通过网络在线下载jdk，制作jdk镜像，这种方式直接copy的地址：<a href="https://github.com/tifayuki/docker-image-java" target="_blank" rel="external">https://github.com/tifayuki/docker-image-java</a><br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">FROM ubuntu:trusty</span><br><span class="line">MAINTAINER Feng Honglin &lt;hfeng@tutum.co&gt;</span><br><span class="line"> </span><br><span class="line"><span class="comment"># Install Oracle Java 7</span></span><br><span class="line">ENV JAVA_VER <span class="number">7</span></span><br><span class="line">ENV JAVA_HOME /usr/lib/jvm/java-<span class="number">7</span>-oracle</span><br><span class="line"> </span><br><span class="line">RUN <span class="built_in">echo</span> <span class="string">'deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main'</span> &gt;&gt; /etc/apt/sources.list &amp;&amp; \</span><br><span class="line">    <span class="built_in">echo</span> <span class="string">'deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main'</span> &gt;&gt; /etc/apt/sources.list &amp;&amp; \</span><br><span class="line">    apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C2518248EEA14886 &amp;&amp; \</span><br><span class="line">    apt-get update &amp;&amp; \</span><br><span class="line">    <span class="built_in">echo</span> oracle-java<span class="variable">$&#123;JAVA_VER&#125;</span>-installer shared/accepted-oracle-license-v1-<span class="number">1</span> select <span class="literal">true</span> | sudo /usr/bin/debconf-set-selections &amp;&amp; \</span><br><span class="line">    apt-get install -y --force-yes --no-install-recommends oracle-java<span class="variable">$&#123;JAVA_VER&#125;</span>-installer oracle-java<span class="variable">$&#123;JAVA_VER&#125;</span>-set-default &amp;&amp; \</span><br><span class="line">    apt-get clean &amp;&amp; \</span><br><span class="line">    rm -rf /var/lib/apt/lists &amp;&amp; \</span><br><span class="line">    rm -rf /var/cache/oracle-jdk<span class="variable">$&#123;JAVA_VER&#125;</span>-installer</span><br></pre></td></tr></table></figure></p>
<p>　　下载地址：<a href="/code/docker-image-java-master.zip">docker-image-java-master.zip</a></p>
<h2 id="Dockerfile_u5728_u7EBF_u5236_u4F5Ctomcat_u955C_u50CF"><a href="#Dockerfile_u5728_u7EBF_u5236_u4F5Ctomcat_u955C_u50CF" class="headerlink" title="Dockerfile在线制作tomcat镜像"></a>Dockerfile在线制作tomcat镜像</h2><p>　　下面我们看看通过网络在线下载tomcat，制作jdk镜像，这种方式直接copy的地址：<a href="https://github.com/tutumcloud/tutum-docker-tomcat.git" target="_blank" rel="external">https://github.com/tutumcloud/tutum-docker-tomcat.git</a><br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line">FROM tifayuki/java:<span class="number">7</span></span><br><span class="line">MAINTAINER Feng Honglin &lt;hfeng@tutum.co&gt;</span><br><span class="line"></span><br><span class="line">RUN apt-get update &amp;&amp; \</span><br><span class="line">    apt-get install -yq --no-install-recommends wget pwgen ca-certificates &amp;&amp; \</span><br><span class="line">    apt-get clean &amp;&amp; \</span><br><span class="line">    rm -rf /var/lib/apt/lists/*</span><br><span class="line"></span><br><span class="line">ENV TOMCAT_MAJOR_VERSION <span class="number">8</span></span><br><span class="line">ENV TOMCAT_MINOR_VERSION <span class="number">8.0</span>.<span class="number">11</span></span><br><span class="line">ENV CATALINA_HOME /tomcat</span><br><span class="line"></span><br><span class="line"><span class="comment"># INSTALL TOMCAT</span></span><br><span class="line">RUN wget -q https://archive.apache.org/dist/tomcat/tomcat-<span class="variable">$&#123;TOMCAT_MAJOR_VERSION&#125;</span>/v<span class="variable">$&#123;TOMCAT_MINOR_VERSION&#125;</span>/bin/apache-tomcat-<span class="variable">$&#123;TOMCAT_MINOR_VERSION&#125;</span>.tar.gz &amp;&amp; \</span><br><span class="line">    wget -qO- https://archive.apache.org/dist/tomcat/tomcat-<span class="variable">$&#123;TOMCAT_MAJOR_VERSION&#125;</span>/v<span class="variable">$&#123;TOMCAT_MINOR_VERSION&#125;</span>/bin/apache-tomcat-<span class="variable">$&#123;TOMCAT_MINOR_VERSION&#125;</span>.tar.gz.md5 | md5sum -c - &amp;&amp; \</span><br><span class="line">    tar zxf apache-tomcat-*.tar.gz &amp;&amp; \</span><br><span class="line">    rm apache-tomcat-*.tar.gz &amp;&amp; \</span><br><span class="line">    mv apache-tomcat* tomcat</span><br><span class="line"></span><br><span class="line">ADD create_tomcat_admin_user.sh /create_tomcat_admin_user.sh</span><br><span class="line">ADD run.sh /run.sh</span><br><span class="line">RUN chmod +x /*.sh</span><br><span class="line"></span><br><span class="line">EXPOSE <span class="number">8080</span></span><br><span class="line">CMD [<span class="string">"/run.sh"</span>]</span><br></pre></td></tr></table></figure></p>
<p>　　所需的create_tomcat_admin_user.sh如下：<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line"><span class="shebang">#!/bin/bash</span><br><span class="line"> </span></span><br><span class="line"><span class="keyword">if</span> [ <span class="operator">-f</span> /.tomcat_admin_created ]; <span class="keyword">then</span></span><br><span class="line">    <span class="built_in">echo</span> <span class="string">"Tomcat 'admin' user already created"</span></span><br><span class="line">    <span class="built_in">exit</span> <span class="number">0</span></span><br><span class="line"><span class="keyword">fi</span></span><br><span class="line"> </span><br><span class="line"><span class="comment">#generate password</span></span><br><span class="line">PASS=<span class="variable">$&#123;TOMCAT_PASS:-$(pwgen -s 12 1)&#125;</span></span><br><span class="line">_word=$( [ <span class="variable">$&#123;TOMCAT_PASS&#125;</span> ] &amp;&amp; <span class="built_in">echo</span> <span class="string">"preset"</span> || <span class="built_in">echo</span> <span class="string">"random"</span> )</span><br><span class="line"> </span><br><span class="line"><span class="built_in">echo</span> <span class="string">"=&gt; Creating and admin user with a <span class="variable">$&#123;_word&#125;</span> password in Tomcat"</span></span><br><span class="line">sed -i -r <span class="string">'s/&lt;\/tomcat-users&gt;//'</span> <span class="variable">$&#123;CATALINA_HOME&#125;</span>/conf/tomcat-users.xml</span><br><span class="line"><span class="built_in">echo</span> <span class="string">'&lt;role rolename="manager-gui"/&gt;'</span> &gt;&gt; <span class="variable">$&#123;CATALINA_HOME&#125;</span>/conf/tomcat-users.xml</span><br><span class="line"><span class="built_in">echo</span> <span class="string">'&lt;role rolename="manager-script"/&gt;'</span> &gt;&gt; <span class="variable">$&#123;CATALINA_HOME&#125;</span>/conf/tomcat-users.xml</span><br><span class="line"><span class="built_in">echo</span> <span class="string">'&lt;role rolename="manager-jmx"/&gt;'</span> &gt;&gt; <span class="variable">$&#123;CATALINA_HOME&#125;</span>/conf/tomcat-users.xml</span><br><span class="line"><span class="built_in">echo</span> <span class="string">'&lt;role rolename="admin-gui"/&gt;'</span> &gt;&gt; <span class="variable">$&#123;CATALINA_HOME&#125;</span>/conf/tomcat-users.xml</span><br><span class="line"><span class="built_in">echo</span> <span class="string">'&lt;role rolename="admin-script"/&gt;'</span> &gt;&gt; <span class="variable">$&#123;CATALINA_HOME&#125;</span>/conf/tomcat-users.xml</span><br><span class="line"><span class="built_in">echo</span> <span class="string">"&lt;user username=\"admin\" password=\"<span class="variable">$&#123;PASS&#125;</span>\" roles=\"manager-gui,manager-script,manager-jmx,admin-gui, admin-script\"/&gt;"</span> &gt;&gt; <span class="variable">$&#123;CATALINA_HOME&#125;</span>/conf/tomcat-users.xml</span><br><span class="line"><span class="built_in">echo</span> <span class="string">'&lt;/tomcat-users&gt;'</span> &gt;&gt; <span class="variable">$&#123;CATALINA_HOME&#125;</span>/conf/tomcat-users.xml </span><br><span class="line"><span class="built_in">echo</span> <span class="string">"=&gt; Done!"</span></span><br><span class="line">touch /.tomcat_admin_created</span><br><span class="line"> </span><br><span class="line"><span class="built_in">echo</span> <span class="string">"========================================================================"</span></span><br><span class="line"><span class="built_in">echo</span> <span class="string">"You can now configure to this Tomcat server using:"</span></span><br><span class="line"><span class="built_in">echo</span> <span class="string">""</span></span><br><span class="line"><span class="built_in">echo</span> <span class="string">"    admin:<span class="variable">$&#123;PASS&#125;</span>"</span></span><br><span class="line"><span class="built_in">echo</span> <span class="string">""</span></span><br><span class="line"><span class="built_in">echo</span> <span class="string">"========================================================================"</span></span><br></pre></td></tr></table></figure></p>
<p>run.sh<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="shebang">#!/bin/bash</span><br><span class="line"> </span></span><br><span class="line"><span class="keyword">if</span> [ ! <span class="operator">-f</span> /.tomcat_admin_created ]; <span class="keyword">then</span></span><br><span class="line">    /create_tomcat_admin_user.sh</span><br><span class="line"><span class="keyword">fi</span></span><br><span class="line"> </span><br><span class="line"><span class="built_in">exec</span> <span class="variable">$&#123;CATALINA_HOME&#125;</span>/bin/catalina.sh run</span><br></pre></td></tr></table></figure></p>
<p>　　下载地址：<a href="/code/tutum-docker-tomcat-master.zip">tutum-docker-tomcat-master.zip</a></p>
<h2 id="u5236_u4F5Cnodejs_u955C_u50CF"><a href="#u5236_u4F5Cnodejs_u955C_u50CF" class="headerlink" title="制作nodejs镜像"></a>制作nodejs镜像</h2><h5 id="1-__u521B_u5EFAnodejs_u5E94_u7528"><a href="#1-__u521B_u5EFAnodejs_u5E94_u7528" class="headerlink" title="1. 创建nodejs应用"></a>1. 创建nodejs应用</h5><p>　　首先在目录src下创建package.json来描述应用程序和依赖关系<br><figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">    "<span class="attribute">name</span>": <span class="value"><span class="string">"docker-centos-hello"</span></span>, </span><br><span class="line">    "<span class="attribute">private</span>": <span class="value"><span class="literal">true</span></span>, </span><br><span class="line">    "<span class="attribute">version</span>": <span class="value"><span class="string">"0.0.1"</span></span>, </span><br><span class="line">    "<span class="attribute">description</span>": <span class="value"><span class="string">"Node.js Hello world app on CentOS using docker"</span></span>, </span><br><span class="line">    "<span class="attribute">author</span>": <span class="value"><span class="string">"Daniel Gasienica &lt;daniel@gasienica.ch&gt;"</span></span>, </span><br><span class="line">    "<span class="attribute">dependencies</span>": <span class="value">&#123;</span><br><span class="line">        "<span class="attribute">express</span>": <span class="value"><span class="string">"3.2.4"</span></span><br><span class="line">    </span>&#125;</span><br><span class="line"></span>&#125;</span><br></pre></td></tr></table></figure></p>
<p>　　然后创建一个index.js文件，使用Express.js框架来做一个web应用程序，监听8080端口。<br><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> express = <span class="built_in">require</span>(<span class="string">'express'</span>);</span><br><span class="line"><span class="keyword">var</span> PORT = <span class="number">8080</span>;</span><br><span class="line"></span><br><span class="line"><span class="keyword">var</span> app = express();</span><br><span class="line">app.get(<span class="string">'/'</span>, <span class="function"><span class="keyword">function</span>(<span class="params">req, res</span>) </span>&#123;</span><br><span class="line">    res.send(<span class="string">'Hello world\n'</span>);</span><br><span class="line">&#125;);</span><br><span class="line"></span><br><span class="line">app.listen(PORT);</span><br><span class="line"><span class="built_in">console</span>.log(<span class="string">'Running on http://localhost:'</span> + PORT);</span><br></pre></td></tr></table></figure></p>
<h5 id="2-__u7F16_u5199Dockerfile_u6587_u4EF6"><a href="#2-__u7F16_u5199Dockerfile_u6587_u4EF6" class="headerlink" title="2. 编写Dockerfile文件"></a>2. 编写Dockerfile文件</h5><p>　　在src目录下创建一个文件：Dockerfile<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 定义构建镜像的顶级镜像</span></span><br><span class="line">FROM    centos:<span class="number">6.4</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 在Centos镜像中安装Node.js</span></span><br><span class="line">RUN rpm -Uvh http://download.fedoraproject.org/pub/epel/<span class="number">6</span>/i386/epel-release-<span class="number">6</span>-<span class="number">8</span>.noarch.rpm</span><br><span class="line"><span class="comment"># Node.js运行应用程序需要使用npm安装package.json中定义的依赖关系</span></span><br><span class="line">RUN yum install -y npm</span><br><span class="line"></span><br><span class="line"><span class="comment"># 将应用程序源代码添加到Docker镜像中</span></span><br><span class="line">ADD . /src</span><br><span class="line"><span class="comment"># 使用npm安装应用程序依赖</span></span><br><span class="line">RUN <span class="built_in">cd</span> /src; npm install</span><br><span class="line"></span><br><span class="line"><span class="comment"># 使用EXPOSE指令将8080端口做docker进程映射</span></span><br><span class="line">EXPOSE  <span class="number">8080</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 使用CMD定义运行时的node服务和应用src/index.js的路径</span></span><br><span class="line">CMD [<span class="string">"node"</span>, <span class="string">"/src/index.js"</span>]</span><br></pre></td></tr></table></figure></p>
<h5 id="3-__u8BBF_u95EE_u5E94_u7528"><a href="#3-__u8BBF_u95EE_u5E94_u7528" class="headerlink" title="3. 访问应用"></a>3. 访问应用</h5><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#创建镜像</span></span><br><span class="line">$ docker build -t shihuacai/centos-node-hello .</span><br><span class="line"></span><br><span class="line"><span class="comment">#运行镜像，-p参数绑定一个公共端口到私有容器端口上</span></span><br><span class="line">$ docker run -p <span class="number">49160</span>:<span class="number">8080</span> <span class="operator">-d</span> shihuacai/centos-node-hello</span><br><span class="line"></span><br><span class="line"><span class="comment">#访问应用</span></span><br><span class="line">curl -i localhost:<span class="number">49160</span></span><br></pre></td></tr></table></figure>
<h2 id="u5236_u4F5Cssh_u3001tomcat_u955C_u50CF"><a href="#u5236_u4F5Cssh_u3001tomcat_u955C_u50CF" class="headerlink" title="制作ssh、tomcat镜像"></a>制作ssh、tomcat镜像</h2><p>　　编写Dockerfile文件<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># VERSION 0.0.1</span></span><br><span class="line">FROM ubuntu</span><br><span class="line">MAINTAINER yongboy <span class="string">"yongboy@gmail.com"</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 更新源，安装ssh server</span></span><br><span class="line">RUN <span class="built_in">echo</span> <span class="string">"deb http://archive.ubuntu.com/ubuntu precise main universe"</span>&gt; /etc/apt/sources.list</span><br><span class="line">RUN apt-get update</span><br><span class="line">RUN apt-get install -y openssh-server</span><br><span class="line">RUN mkdir -p /var/run/sshd</span><br><span class="line"></span><br><span class="line"><span class="comment"># 设置root ssh远程登录密码为123456</span></span><br><span class="line">RUN <span class="built_in">echo</span> <span class="string">"root:123456"</span> | chpasswd </span><br><span class="line"></span><br><span class="line"><span class="comment"># 添加orache java7源，一次性安装vim，wget，curl，java7，tomcat7等必备软件</span></span><br><span class="line">RUN apt-get install python-software-properties</span><br><span class="line">RUN add-apt-repository ppa:webupd8team/java</span><br><span class="line">RUN apt-get update</span><br><span class="line">RUN apt-get install -y vim wget curl oracle-java7-installer tomcat7</span><br><span class="line"></span><br><span class="line"><span class="comment"># 设置JAVA_HOME环境变量</span></span><br><span class="line">RUN update-alternatives --display java</span><br><span class="line">RUN <span class="built_in">echo</span> <span class="string">"JAVA_HOME=/usr/lib/jvm/java-7-oracle"</span> &gt;&gt; /etc/environment</span><br><span class="line">RUN <span class="built_in">echo</span> <span class="string">"JAVA_HOME=/usr/lib/jvm/java-7-oracle"</span> &gt;&gt; /etc/default/tomcat7</span><br><span class="line"></span><br><span class="line"><span class="comment"># 容器需要开放SSH 22端口</span></span><br><span class="line">EXPOSE <span class="number">22</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 容器需要开放Tomcat 8080端口</span></span><br><span class="line">EXPOSE <span class="number">8080</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 设置Tomcat7初始化运行，SSH终端服务器作为后台运行</span></span><br><span class="line">ENTRYPOINT service tomcat7 start &amp;&amp; /usr/sbin/sshd -D</span><br></pre></td></tr></table></figure></p>
<p>需要注意：<br>　　1. ENTRYPOINT，表示镜像在初始化时需要执行的命令，不可被重写覆盖，需谨记<br>　　2. CMD，表示镜像运行默认参数，可被重写覆盖<br>　　3. ENTRYPOINT/CMD都只能在文件中存在一次，并且最后一个生效，存在多个，只有最后一个生效，其它无效！需要初始化运行多个命令，彼此之间可以使用 &amp;&amp; 隔开，但最后一个须要为无限运行的命令，需切记！<br>　　在Docker daemon模式下，无论是使用ENTRYPOINT，还是CMD，Dockerfile中最后的命令，一定要是当前进程需要一直运行的，才能够防容器退出。<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 无效</span></span><br><span class="line">$ ENTRYPOINT service tomcat7 start <span class="comment">#运行几秒钟之后，容器就会退出</span></span><br><span class="line">$ CMD service tomcat7 start <span class="comment">#运行几秒钟之后，容器就会退出</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 这样有效</span></span><br><span class="line">$ ENTRYPOINT service tomcat7 start &amp;&amp; tail <span class="operator">-f</span> /var/lib/tomcat7/logs/catalina.out</span><br><span class="line"><span class="comment"># 或者</span></span><br><span class="line">$ CMD service tomcat7 start &amp;&amp; tail <span class="operator">-f</span> /var/lib/tomcat7/logs/catalina.out</span><br><span class="line">这样也有效：</span><br><span class="line">$ ENTRYPOINT [<span class="string">"/usr/sbin/sshd"</span>]</span><br><span class="line">$ CMD [<span class="string">"-D"</span>]</span><br></pre></td></tr></table></figure></p>
<p>　　在Dockerfile中，若没有使用ENTRYPOINT/CMD指令，若运行多个命令，可以这样做：<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker run <span class="operator">-d</span> -p <span class="number">22</span> -p <span class="number">8080</span> yongboy/java7 /bin/sh -c <span class="string">"service tomcat7 start &amp;&amp; /usr/sbin/sshd -D"</span></span><br></pre></td></tr></table></figure></p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2016/01/10/docker/2.docker系列之制作镜像/" data-id="cijzzpvgl00fx1cfsxuu7lfg9" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/docker/">docker</a></li></ul>

    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/2016/01/10/docker/3.docker系列之Registry/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          docker系列三之Registry
        
      </div>
    </a>
  
  
    <a href="/2016/01/10/docker/1.docker系列之简介/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title">docker系列一之简介</div>
    </a>
  
</nav>

  
</article>

</section>
        
          <aside id="sidebar">
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Categories</h3>
    <div class="widget">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/cache/">cache</a><span class="category-list-count">3</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/database/">database</a><span class="category-list-count">13</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/docker/">docker</a><span class="category-list-count">6</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/gis/">gis</a><span class="category-list-count">4</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/git/">git</a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/go/">go</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/gradle/">gradle</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/groovy/">groovy</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/hadoop/">hadoop</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/java/">java</a><span class="category-list-count">18</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/linux/">linux</a><span class="category-list-count">4</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/log/">log</a><span class="category-list-count">11</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/mongodb/">mongodb</a><span class="category-list-count">14</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/mq/">mq</a><span class="category-list-count">6</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/mybatis/">mybatis</a><span class="category-list-count">9</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/netty/">netty</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/nginx/">nginx</a><span class="category-list-count">3</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/nio/">nio</a><span class="category-list-count">19</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/nodejs/">nodejs</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/redis/">redis</a><span class="category-list-count">6</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/rpc/">rpc</a><span class="category-list-count">14</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/spring/">spring</a><span class="category-list-count">5</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/tomcat/">tomcat</a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/zookeeper/">zookeeper</a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/杂项/">杂项</a><span class="category-list-count">2</span></li></ul>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tags</h3>
    <div class="widget">
      <ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="/tags/aop/">aop</a><span class="tag-list-count">8</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/aspectj/">aspectj</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/cache/">cache</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/classloader/">classloader</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/common-loggings/">common-loggings</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/commonjs/">commonjs</a><span class="tag-list-count">4</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/database/">database</a><span class="tag-list-count">10</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/docker/">docker</a><span class="tag-list-count">6</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/dubbo/">dubbo</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/fastdfs/">fastdfs</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/gclib/">gclib</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/geohash/">geohash</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/gis/">gis</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/git/">git</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/go/">go</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/gradle/">gradle</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/groovy/">groovy</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/hadoop/">hadoop</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/hessisan/">hessisan</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/java/">java</a><span class="tag-list-count">48</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/javassist/">javassist</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/kafka/">kafka</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/linux/">linux</a><span class="tag-list-count">4</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/log/">log</a><span class="tag-list-count">11</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/log4j/">log4j</a><span class="tag-list-count">4</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/logback/">logback</a><span class="tag-list-count">5</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/map/">map</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/memecached/">memecached</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/mina/">mina</a><span class="tag-list-count">5</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/mongodb/">mongodb</a><span class="tag-list-count">14</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/mq/">mq</a><span class="tag-list-count">6</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/mqtt/">mqtt</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/mybatis/">mybatis</a><span class="tag-list-count">9</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/netty/">netty</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/nginx/">nginx</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/nio/">nio</a><span class="tag-list-count">5</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/nodejs/">nodejs</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/postgresql/">postgresql</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/protobuf/">protobuf</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/proxy/">proxy</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/push/">push</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/rabbitmq/">rabbitmq</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/redis/">redis</a><span class="tag-list-count">6</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/rpc/">rpc</a><span class="tag-list-count">14</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/sitemesh/">sitemesh</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/sld/">sld</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/slf4j/">slf4j</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/socket/">socket</a><span class="tag-list-count">7</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/spatialite-for-android/">spatialite for android</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/spi/">spi</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/spring/">spring</a><span class="tag-list-count">13</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/tomcat/">tomcat</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/transaction/">transaction</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/web/">web</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/xSocket/">xSocket</a><span class="tag-list-count">7</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/zbus/">zbus</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/zookeeper/">zookeeper</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/数据结构/">数据结构</a><span class="tag-list-count">2</span></li></ul>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tag Cloud</h3>
    <div class="widget tagcloud">
      <a href="/tags/aop/" style="font-size: 15.38px;">aop</a> <a href="/tags/aspectj/" style="font-size: 11.54px;">aspectj</a> <a href="/tags/cache/" style="font-size: 11.54px;">cache</a> <a href="/tags/classloader/" style="font-size: 10px;">classloader</a> <a href="/tags/common-loggings/" style="font-size: 10px;">common-loggings</a> <a href="/tags/commonjs/" style="font-size: 12.31px;">commonjs</a> <a href="/tags/database/" style="font-size: 16.92px;">database</a> <a href="/tags/docker/" style="font-size: 13.85px;">docker</a> <a href="/tags/dubbo/" style="font-size: 10px;">dubbo</a> <a href="/tags/fastdfs/" style="font-size: 10px;">fastdfs</a> <a href="/tags/gclib/" style="font-size: 10.77px;">gclib</a> <a href="/tags/geohash/" style="font-size: 10px;">geohash</a> <a href="/tags/gis/" style="font-size: 10px;">gis</a> <a href="/tags/git/" style="font-size: 10.77px;">git</a> <a href="/tags/go/" style="font-size: 10px;">go</a> <a href="/tags/gradle/" style="font-size: 10px;">gradle</a> <a href="/tags/groovy/" style="font-size: 10px;">groovy</a> <a href="/tags/hadoop/" style="font-size: 10px;">hadoop</a> <a href="/tags/hessisan/" style="font-size: 11.54px;">hessisan</a> <a href="/tags/java/" style="font-size: 20px;">java</a> <a href="/tags/javassist/" style="font-size: 10px;">javassist</a> <a href="/tags/kafka/" style="font-size: 11.54px;">kafka</a> <a href="/tags/linux/" style="font-size: 12.31px;">linux</a> <a href="/tags/log/" style="font-size: 17.69px;">log</a> <a href="/tags/log4j/" style="font-size: 12.31px;">log4j</a> <a href="/tags/logback/" style="font-size: 13.08px;">logback</a> <a href="/tags/map/" style="font-size: 10px;">map</a> <a href="/tags/memecached/" style="font-size: 10.77px;">memecached</a> <a href="/tags/mina/" style="font-size: 13.08px;">mina</a> <a href="/tags/mongodb/" style="font-size: 19.23px;">mongodb</a> <a href="/tags/mq/" style="font-size: 13.85px;">mq</a> <a href="/tags/mqtt/" style="font-size: 10.77px;">mqtt</a> <a href="/tags/mybatis/" style="font-size: 16.15px;">mybatis</a> <a href="/tags/netty/" style="font-size: 10px;">netty</a> <a href="/tags/nginx/" style="font-size: 11.54px;">nginx</a> <a href="/tags/nio/" style="font-size: 13.08px;">nio</a> <a href="/tags/nodejs/" style="font-size: 10px;">nodejs</a> <a href="/tags/postgresql/" style="font-size: 10.77px;">postgresql</a> <a href="/tags/protobuf/" style="font-size: 10px;">protobuf</a> <a href="/tags/proxy/" style="font-size: 10px;">proxy</a> <a href="/tags/push/" style="font-size: 10px;">push</a> <a href="/tags/rabbitmq/" style="font-size: 11.54px;">rabbitmq</a> <a href="/tags/redis/" style="font-size: 13.85px;">redis</a> <a href="/tags/rpc/" style="font-size: 19.23px;">rpc</a> <a href="/tags/sitemesh/" style="font-size: 10px;">sitemesh</a> <a href="/tags/sld/" style="font-size: 10px;">sld</a> <a href="/tags/slf4j/" style="font-size: 10px;">slf4j</a> <a href="/tags/socket/" style="font-size: 14.62px;">socket</a> <a href="/tags/spatialite-for-android/" style="font-size: 10px;">spatialite for android</a> <a href="/tags/spi/" style="font-size: 10px;">spi</a> <a href="/tags/spring/" style="font-size: 18.46px;">spring</a> <a href="/tags/tomcat/" style="font-size: 10.77px;">tomcat</a> <a href="/tags/transaction/" style="font-size: 10px;">transaction</a> <a href="/tags/web/" style="font-size: 10px;">web</a> <a href="/tags/xSocket/" style="font-size: 14.62px;">xSocket</a> <a href="/tags/zbus/" style="font-size: 10px;">zbus</a> <a href="/tags/zookeeper/" style="font-size: 10.77px;">zookeeper</a> <a href="/tags/数据结构/" style="font-size: 10.77px;">数据结构</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/01/">January 2016</a><span class="archive-list-count">67</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/12/">December 2015</a><span class="archive-list-count">81</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/11/">November 2015</a><span class="archive-list-count">2</span></li></ul>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recents</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2016/01/30/资料/">(no title)</a>
          </li>
        
          <li>
            <a href="/2016/01/30/java/13.Classloader系列一/">ClassLoader系列一</a>
          </li>
        
          <li>
            <a href="/2016/01/29/hadoop/1.hadoop系列之源码编译/">hadoop系列一之源码编译</a>
          </li>
        
          <li>
            <a href="/2016/01/29/go/1.GO系列之入门/">Go系列一之入门</a>
          </li>
        
          <li>
            <a href="/2016/01/28/tomcat/2.tomcat性能优化/">tomcat性能优化</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2016 John Doe<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    


<script src="http://libs.baidu.com/jquery/2.0.3/jquery.min.js"></script>


  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css" type="text/css">
  <script src="/fancybox/jquery.fancybox.pack.js" type="text/javascript"></script>


<script src="/js/script.js" type="text/javascript"></script>

  </div>
</body>
</html>